package edu.jxnu.zhangjinsong.unemploymenttracker.ai.controller;

import edu.jxnu.zhangjinsong.unemploymenttracker.config.properties.OllamaProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/ai")
@CrossOrigin(origins = "*")
public class ChatClientController {

    @Autowired
    private OllamaProperties ollamaProperties;

    @Autowired
    @Qualifier("deepseek-r1")
    private ChatClient deepseekR1;

    @Autowired
    @Qualifier("gpt-3.5-turbo")
    private ChatClient gpt_3_Turbo;

    @PostMapping("/chat")
    public String chat(@RequestBody Map<String, String> params) {
        String message = params.get("message");
        return deepseekR1.prompt().user(message).call().content();
    }
}